<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>


<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-ads-add" method="post" enctype="multipart/form-data" action="addAndUpload">
        <div class="form-group">
            <label class="col-sm-3 control-label">广告名称：</label>
            <div class="col-sm-8">
                <input id="adsMc" name="adsMc" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">停留时长：</label>
            <div class="col-sm-8">
                <input id="adsBfsj" name="adsBfsj" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">广告模式：</label>
            <div class="col-sm-8">
                <select id="adsType" name="adsType" class="form-control">
                    <option value="0">通用广告</option>
                    <option value="1">个性广告</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">广告位置：</label>
            <div class="col-sm-8">
                <input id="treeName" name="adsSsdq" onclick="selectDeptTree()" readonly="true" class="form-control"
                       type="text">
                <input id="treeId" name="adsSsdqId" class="form-control" type="hidden">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属快递柜：</label>
            <div class="col-sm-8">
                <input id="boxGuid" name="boxGuid" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">广告播放顺序：</label>
            <div class="col-sm-8">
                <input id="adsNo" name="adsNo" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">广告详情：</label>
            <div class="col-sm-8">
                <input name="adsFile" id="adsFile" type="file" class="file"/>
            </div>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">提交</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>

<script type="text/javascript">
    var prefix = ctx + "ebox/ads"
    $("#form-ads-add").validate({
        rules: {
            adsMc: {
                required: true
            },
            adsBfsj: {
                required: true
            },
            adsType: {
                required: true
            },
            treeName: {
                required: true
            },
            boxGuid: {
                required: false
            },
            adsNo: {
                required: true,
                regexp: /^[0-9]+$/
            },
            adsFile: {
                required: true
            }
        },
        submitHandler: function (form) {
            //$.operate.saveAndUpload(prefix + "/add", $('#form-ads-add').serialize());
            $("#form-ads-add").submit();
        }
    });

    /*用户管理-新增-选择部门树*/
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = treeId == null || treeId == "" ? "100" : treeId;
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        $.modal.open("选择部门", url, '380', '380');
    }

    function getEbox() {

    }

</script>
</body>
</html>
